// /**
//  * Copyright (c) 2014-present, Facebook, Inc.
//  *
//  * This source code is licensed under the MIT license found in the
//  * LICENSE file in the root directory of this source tree.
//  */

// (function (global, factory) {
//   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
//     typeof define === 'function' && define.amd ? define(factory) :
//       (global.ES6Promise = factory(), ES6Promise.polyfill(), global.Promise = ES6Promise);
// }(window || this, (function () {
//   'use strict';

//   function objectOrFunction(x) {
//     var type = typeof x;
//     return x !== null && (type === 'object' || type === 'function');
//   }

//   function isFunction(x) {
//     return typeof x === 'function';
//   }

//   var _isArray = void 0;
//   if (Array.isArray) {
//     _isArray = Array.isArray;
//   } else {
//     _isArray = function (x) {
//       return Object.prototype.toString.call(x) === '[object Array]';
//     };
//   }

//   var isArray = _isArray;

//   var len = 0;
//   var vertxNext = void 0;
//   var customSchedulerFn = void 0;

//   var asap = function asap(callback, arg) {
//     queue[len] = callback;
//     queue[len + 1] = arg;
//     len += 2;
//     if (len === 2) {
//       // If len is 2, that means that we need to schedule an async flush.
//       // If additional callbacks are queued before the queue is flushed, they
//       // will be processed by this flush that we are scheduling.
//       if (customSchedulerFn) {
//         customSchedulerFn(flush);
//       } else {
//         scheduleFlush();
//       }
//     }
//   };

//   function setScheduler(scheduleFn) {
//     customSchedulerFn = scheduleFn;
//   }

//   function setAsap(asapFn) {
//     asap = asapFn;
//   }

//   var browserWindow = typeof window !== 'undefined' ? window : undefined;
//   var browserGlobal = browserWindow || {};
//   var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
//   var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';

//   // test for web worker but not in IE10
//   var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';

//   // node
//   function useNextTick() {
//     // node version 0.10.x displays a deprecation warning when nextTick is used recursively
//     // see https://github.com/cujojs/when/issues/410 for details
//     return function () {
//       return process.nextTick(flush);
//     };
//   }

//   // vertx
//   function useVertxTimer() {
//     if (typeof vertxNext !== 'undefined') {
//       return function () {
//         vertxNext(flush);
//       };
//     }

//     return useSetTimeout();
//   }

//   function useMutationObserver() {
//     var iterations = 0;
//     var observer = new BrowserMutationObserver(flush);
//     var node = document.createTextNode('');
//     observer.observe(node, { characterData: true });

//     return function () {
//       node.data = iterations = ++iterations % 2;
//     };
//   }

//   // web worker
//   function useMessageChannel() {
//     var channel = new MessageChannel();
//     channel.port1.onmessage = flush;
//     return function () {
//       return channel.port2.postMessage(0);
//     };
//   }

//   function useSetTimeout() {
//     // Store setTimeout reference so es6-promise will be unaffected by
//     // other code modifying setTimeout (like sinon.useFakeTimers())
//     var globalSetTimeout = setTimeout;
//     return function () {
//       return globalSetTimeout(flush, 1);
//     };
//   }

//   var queue = new Array(1000);
//   function flush() {
//     for (var i = 0; i < len; i += 2) {
//       var callback = queue[i];
//       var arg = queue[i + 1];

//       callback(arg);

//       queue[i] = undefined;
//       queue[i + 1] = undefined;
//     }

//     len = 0;
//   }

//   function attemptVertx() {
//     try {
//       var r = require;
//       var vertx = r('vertx');
//       vertxNext = vertx.runOnLoop || vertx.runOnContext;
//       return useVertxTimer();
//     } catch (e) {
//       return useSetTimeout();
//     }
//   }

//   var scheduleFlush = void 0;
//   // Decide what async method to use to triggering processing of queued callbacks:
//   if (isNode) {
//     scheduleFlush = useNextTick();
//   } else if (BrowserMutationObserver) {
//     scheduleFlush = useMutationObserver();
//   } else if (isWorker) {
//     scheduleFlush = useMessageChannel();
//   } else if (browserWindow === undefined && typeof require === 'function') {
//     scheduleFlush = attemptVertx();
//   } else {
//     scheduleFlush = useSetTimeout();
//   }

//   function then(onFulfillment, onRejection) {
//     var parent = this;

//     var child = new this.constructor(noop);

//     if (child[PROMISE_ID] === undefined) {
//       makePromise(child);
//     }

//     var _state = parent._state;


//     if (_state) {
//       var callback = arguments[_state - 1];
//       asap(function () {
//         return invokeCallback(_state, child, callback, parent._result);
//       });
//     } else {
//       subscribe(parent, child, onFulfillment, onRejection);
//     }

//     return child;
//   }

//   /**
//     `Promise.resolve` returns a promise that will become resolved with the
//     passed `value`. It is shorthand for the following:
  
//     ```javascript
//     let promise = new Promise(function(resolve, reject){
//       resolve(1);
//     });
  
//     promise.then(function(value){
//       // value === 1
//     });
//     ```
  
//     Instead of writing the above, your code now simply becomes the following:
  
//     ```javascript
//     let promise = Promise.resolve(1);
  
//     promise.then(function(value){
//       // value === 1
//     });
//     ```
  
//     @method resolve
//     @static
//     @param {Any} value value that the returned promise will be resolved with
//     Useful for tooling.
//     @return {Promise} a promise that will become fulfilled with the given
//     `value`
//   */
//   function resolve$1(object) {
//     /*jshint validthis:true */
//     var Constructor = this;

//     if (object && typeof object === 'object' && object.constructor === Constructor) {
//       return object;
//     }

//     var promise = new Constructor(noop);
//     resolve(promise, object);
//     return promise;
//   }

//   var PROMISE_ID = Math.random().toString(36).substring(16);

//   function noop() { }

//   var PENDING = void 0;
//   var FULFILLED = 1;
//   var REJECTED = 2;

//   var GET_THEN_ERROR = new ErrorObject();

//   function selfFulfillment() {
//     return new TypeError("You cannot resolve a promise with itself");
//   }

//   function cannotReturnOwn() {
//     return new TypeError('A promises callback cannot return that same promise.');
//   }

//   function getThen(promise) {
//     try {
//       return promise.then;
//     } catch (error) {
//       GET_THEN_ERROR.error = error;
//       return GET_THEN_ERROR;
//     }
//   }

//   function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
//     try {
//       then$$1.call(value, fulfillmentHandler, rejectionHandler);
//     } catch (e) {
//       return e;
//     }
//   }

//   function handleForeignThenable(promise, thenable, then$$1) {
//     asap(function (promise) {
//       var sealed = false;
//       var error = tryThen(then$$1, thenable, function (value) {
//         if (sealed) {
//           return;
//         }
//         sealed = true;
//         if (thenable !== value) {
//           resolve(promise, value);
//         } else {
//           fulfill(promise, value);
//         }
//       }, function (reason) {
//         if (sealed) {
//           return;
//         }
//         sealed = true;

//         reject(promise, reason);
//       }, 'Settle: ' + (promise._label || ' unknown promise'));

//       if (!sealed && error) {
//         sealed = true;
//         reject(promise, error);
//       }
//     }, promise);
//   }

//   function handleOwnThenable(promise, thenable) {
//     if (thenable._state === FULFILLED) {
//       fulfill(promise, thenable._result);
//     } else if (thenable._state === REJECTED) {
//       reject(promise, thenable._result);
//     } else {
//       subscribe(thenable, undefined, function (value) {
//         return resolve(promise, value);
//       }, function (reason) {
//         return reject(promise, reason);
//       });
//     }
//   }

//   function handleMaybeThenable(promise, maybeThenable, then$$1) {
//     if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
//       handleOwnThenable(promise, maybeThenable);
//     } else {
//       if (then$$1 === GET_THEN_ERROR) {
//         reject(promise, GET_THEN_ERROR.error);
//         GET_THEN_ERROR.error = null;
//       } else if (then$$1 === undefined) {
//         fulfill(promise, maybeThenable);
//       } else if (isFunction(then$$1)) {
//         handleForeignThenable(promise, maybeThenable, then$$1);
//       } else {
//         fulfill(promise, maybeThenable);
//       }
//     }
//   }

//   function resolve(promise, value) {
//     if (promise === value) {
//       reject(promise, selfFulfillment());
//     } else if (objectOrFunction(value)) {
//       handleMaybeThenable(promise, value, getThen(value));
//     } else {
//       fulfill(promise, value);
//     }
//   }

//   function publishRejection(promise) {
//     if (promise._onerror) {
//       promise._onerror(promise._result);
//     }

//     publish(promise);
//   }

//   function fulfill(promise, value) {
//     if (promise._state !== PENDING) {
//       return;
//     }

//     promise._result = value;
//     promise._state = FULFILLED;

//     if (promise._subscribers.length !== 0) {
//       asap(publish, promise);
//     }
//   }

//   function reject(promise, reason) {
//     if (promise._state !== PENDING) {
//       return;
//     }
//     promise._state = REJECTED;
//     promise._result = reason;

//     asap(publishRejection, promise);
//   }

//   function subscribe(parent, child, onFulfillment, onRejection) {
//     var _subscribers = parent._subscribers;
//     var length = _subscribers.length;


//     parent._onerror = null;

//     _subscribers[length] = child;
//     _subscribers[length + FULFILLED] = onFulfillment;
//     _subscribers[length + REJECTED] = onRejection;

//     if (length === 0 && parent._state) {
//       asap(publish, parent);
//     }
//   }

//   function publish(promise) {
//     var subscribers = promise._subscribers;
//     var settled = promise._state;

//     if (subscribers.length === 0) {
//       return;
//     }

//     var child = void 0,
//       callback = void 0,
//       detail = promise._result;

//     for (var i = 0; i < subscribers.length; i += 3) {
//       child = subscribers[i];
//       callback = subscribers[i + settled];

//       if (child) {
//         invokeCallback(settled, child, callback, detail);
//       } else {
//         callback(detail);
//       }
//     }

//     promise._subscribers.length = 0;
//   }

//   function ErrorObject() {
//     this.error = null;
//   }

//   var TRY_CATCH_ERROR = new ErrorObject();

//   function tryCatch(callback, detail) {
//     try {
//       return callback(detail);
//     } catch (e) {
//       TRY_CATCH_ERROR.error = e;
//       return TRY_CATCH_ERROR;
//     }
//   }

//   function invokeCallback(settled, promise, callback, detail) {
//     var hasCallback = isFunction(callback),
//       value = void 0,
//       error = void 0,
//       succeeded = void 0,
//       failed = void 0;

//     if (hasCallback) {
//       value = tryCatch(callback, detail);

//       if (value === TRY_CATCH_ERROR) {
//         failed = true;
//         error = value.error;
//         value.error = null;
//       } else {
//         succeeded = true;
//       }

//       if (promise === value) {
//         reject(promise, cannotReturnOwn());
//         return;
//       }
//     } else {
//       value = detail;
//       succeeded = true;
//     }

//     if (promise._state !== PENDING) {
//       // noop
//     } else if (hasCallback && succeeded) {
//       resolve(promise, value);
//     } else if (failed) {
//       reject(promise, error);
//     } else if (settled === FULFILLED) {
//       fulfill(promise, value);
//     } else if (settled === REJECTED) {
//       reject(promise, value);
//     }
//   }

//   function initializePromise(promise, resolver) {
//     try {
//       resolver(function resolvePromise(value) {
//         resolve(promise, value);
//       }, function rejectPromise(reason) {
//         reject(promise, reason);
//       });
//     } catch (e) {
//       reject(promise, e);
//     }
//   }

//   var id = 0;
//   function nextId() {
//     return id++;
//   }

//   function makePromise(promise) {
//     promise[PROMISE_ID] = id++;
//     promise._state = undefined;
//     promise._result = undefined;
//     promise._subscribers = [];
//   }

//   function validationError() {
//     return new Error('Array Methods must be provided an Array');
//   }

//   function validationError() {
//     return new Error('Array Methods must be provided an Array');
//   }

//   var Enumerator = function () {
//     function Enumerator(Constructor, input) {
//       this._instanceConstructor = Constructor;
//       this.promise = new Constructor(noop);

//       if (!this.promise[PROMISE_ID]) {
//         makePromise(this.promise);
//       }

//       if (isArray(input)) {
//         this.length = input.length;
//         this._remaining = input.length;

//         this._result = new Array(this.length);

//         if (this.length === 0) {
//           fulfill(this.promise, this._result);
//         } else {
//           this.length = this.length || 0;
//           this._enumerate(input);
//           if (this._remaining === 0) {
//             fulfill(this.promise, this._result);
//           }
//         }
//       } else {
//         reject(this.promise, validationError());
//       }
//     }

//     Enumerator.prototype._enumerate = function _enumerate(input) {
//       for (var i = 0; this._state === PENDING && i < input.length; i++) {
//         this._eachEntry(input[i], i);
//       }
//     };

//     Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {
//       var c = this._instanceConstructor;
//       var resolve$$1 = c.resolve;


//       if (resolve$$1 === resolve$1) {
//         var _then = getThen(entry);

//         if (_then === then && entry._state !== PENDING) {
//           this._settledAt(entry._state, i, entry._result);
//         } else if (typeof _then !== 'function') {
//           this._remaining--;
//           this._result[i] = entry;
//         } else if (c === Promise$1) {
//           var promise = new c(noop);
//           handleMaybeThenable(promise, entry, _then);
//           this._willSettleAt(promise, i);
//         } else {
//           this._willSettleAt(new c(function (resolve$$1) {
//             return resolve$$1(entry);
//           }), i);
//         }
//       } else {
//         this._willSettleAt(resolve$$1(entry), i);
//       }
//     };

//     Enumerator.prototype._settledAt = function _settledAt(state, i, value) {
//       var promise = this.promise;


//       if (promise._state === PENDING) {
//         this._remaining--;

//         if (state === REJECTED) {
//           reject(promise, value);
//         } else {
//           this._result[i] = value;
//         }
//       }

//       if (this._remaining === 0) {
//         fulfill(promise, this._result);
//       }
//     };

//     Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {
//       var enumerator = this;

//       subscribe(promise, undefined, function (value) {
//         return enumerator._settledAt(FULFILLED, i, value);
//       }, function (reason) {
//         return enumerator._settledAt(REJECTED, i, reason);
//       });
//     };

//     return Enumerator;
//   }();

//   /**
//     `Promise.all` accepts an array of promises, and returns a new promise which
//     is fulfilled with an array of fulfillment values for the passed promises, or
//     rejected with the reason of the first passed promise to be rejected. It casts all
//     elements of the passed iterable to promises as it runs this algorithm.
  
//     Example:
  
//     ```javascript
//     let promise1 = resolve(1);
//     let promise2 = resolve(2);
//     let promise3 = resolve(3);
//     let promises = [ promise1, promise2, promise3 ];
  
//     Promise.all(promises).then(function(array){
//       // The array here would be [ 1, 2, 3 ];
//     });
//     ```
  
//     If any of the `promises` given to `all` are rejected, the first promise
//     that is rejected will be given as an argument to the returned promises's
//     rejection handler. For example:
  
//     Example:
  
//     ```javascript
//     let promise1 = resolve(1);
//     let promise2 = reject(new Error("2"));
//     let promise3 = reject(new Error("3"));
//     let promises = [ promise1, promise2, promise3 ];
  
//     Promise.all(promises).then(function(array){
//       // Code here never runs because there are rejected promises!
//     }, function(error) {
//       // error.message === "2"
//     });
//     ```
  
//     @method all
//     @static
//     @param {Array} entries array of promises
//     @param {String} label optional string for labeling the promise.
//     Useful for tooling.
//     @return {Promise} promise that is fulfilled when all `promises` have been
//     fulfilled, or rejected if any of them become rejected.
//     @static
//   */
//   function all(entries) {
//     return new Enumerator(this, entries).promise;
//   }

//   /**
//     `Promise.race` returns a new promise which is settled in the same way as the
//     first passed promise to settle.
  
//     Example:
  
//     ```javascript
//     let promise1 = new Promise(function(resolve, reject){
//       setTimeout(function(){
//         resolve('promise 1');
//       }, 200);
//     });
  
//     let promise2 = new Promise(function(resolve, reject){
//       setTimeout(function(){
//         resolve('promise 2');
//       }, 100);
//     });
  
//     Promise.race([promise1, promise2]).then(function(result){
//       // result === 'promise 2' because it was resolved before promise1
//       // was resolved.
//     });
//     ```
  
//     `Promise.race` is deterministic in that only the state of the first
//     settled promise matters. For example, even if other promises given to the
//     `promises` array argument are resolved, but the first settled promise has
//     become rejected before the other promises became fulfilled, the returned
//     promise will become rejected:
  
//     ```javascript
//     let promise1 = new Promise(function(resolve, reject){
//       setTimeout(function(){
//         resolve('promise 1');
//       }, 200);
//     });
  
//     let promise2 = new Promise(function(resolve, reject){
//       setTimeout(function(){
//         reject(new Error('promise 2'));
//       }, 100);
//     });
  
//     Promise.race([promise1, promise2]).then(function(result){
//       // Code here never runs
//     }, function(reason){
//       // reason.message === 'promise 2' because promise 2 became rejected before
//       // promise 1 became fulfilled
//     });
//     ```
  
//     An example real-world use case is implementing timeouts:
  
//     ```javascript
//     Promise.race([ajax('foo.json'), timeout(5000)])
//     ```
  
//     @method race
//     @static
//     @param {Array} promises array of promises to observe
//     Useful for tooling.
//     @return {Promise} a promise which settles in the same way as the first passed
//     promise to settle.
//   */
//   function race(entries) {
//     /*jshint validthis:true */
//     var Constructor = this;

//     if (!isArray(entries)) {
//       return new Constructor(function (_, reject) {
//         return reject(new TypeError('You must pass an array to race.'));
//       });
//     } else {
//       return new Constructor(function (resolve, reject) {
//         var length = entries.length;
//         for (var i = 0; i < length; i++) {
//           Constructor.resolve(entries[i]).then(resolve, reject);
//         }
//       });
//     }
//   }

//   /**
//     `Promise.reject` returns a promise rejected with the passed `reason`.
//     It is shorthand for the following:
  
//     ```javascript
//     let promise = new Promise(function(resolve, reject){
//       reject(new Error('WHOOPS'));
//     });
  
//     promise.then(function(value){
//       // Code here doesn't run because the promise is rejected!
//     }, function(reason){
//       // reason.message === 'WHOOPS'
//     });
//     ```
  
//     Instead of writing the above, your code now simply becomes the following:
  
//     ```javascript
//     let promise = Promise.reject(new Error('WHOOPS'));
  
//     promise.then(function(value){
//       // Code here doesn't run because the promise is rejected!
//     }, function(reason){
//       // reason.message === 'WHOOPS'
//     });
//     ```
  
//     @method reject
//     @static
//     @param {Any} reason value that the returned promise will be rejected with.
//     Useful for tooling.
//     @return {Promise} a promise rejected with the given `reason`.
//   */
//   function reject$1(reason) {
//     /*jshint validthis:true */
//     var Constructor = this;
//     var promise = new Constructor(noop);
//     reject(promise, reason);
//     return promise;
//   }

//   function needsResolver() {
//     throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
//   }

//   function needsNew() {
//     throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
//   }

//   /**
//     Promise objects represent the eventual result of an asynchronous operation. The
//     primary way of interacting with a promise is through its `then` method, which
//     registers callbacks to receive either a promise's eventual value or the reason
//     why the promise cannot be fulfilled.
  
//     Terminology
//     -----------
  
//     - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
//     - `thenable` is an object or function that defines a `then` method.
//     - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
//     - `exception` is a value that is thrown using the throw statement.
//     - `reason` is a value that indicates why a promise was rejected.
//     - `settled` the final resting state of a promise, fulfilled or rejected.
  
//     A promise can be in one of three states: pending, fulfilled, or rejected.
  
//     Promises that are fulfilled have a fulfillment value and are in the fulfilled
//     state.  Promises that are rejected have a rejection reason and are in the
//     rejected state.  A fulfillment value is never a thenable.
  
//     Promises can also be said to *resolve* a value.  If this value is also a
//     promise, then the original promise's settled state will match the value's
//     settled state.  So a promise that *resolves* a promise that rejects will
//     itself reject, and a promise that *resolves* a promise that fulfills will
//     itself fulfill.
  
  
//     Basic Usage:
//     ------------
  
//     ```js
//     let promise = new Promise(function(resolve, reject) {
//       // on success
//       resolve(value);
  
//       // on failure
//       reject(reason);
//     });
  
//     promise.then(function(value) {
//       // on fulfillment
//     }, function(reason) {
//       // on rejection
//     });
//     ```
  
//     Advanced Usage:
//     ---------------
  
//     Promises shine when abstracting away asynchronous interactions such as
//     `XMLHttpRequest`s.
  
//     ```js
//     function getJSON(url) {
//       return new Promise(function(resolve, reject){
//         let xhr = new XMLHttpRequest();
  
//         xhr.open('GET', url);
//         xhr.onreadystatechange = handler;
//         xhr.responseType = 'json';
//         xhr.setRequestHeader('Accept', 'application/json');
//         xhr.send();
  
//         function handler() {
//           if (this.readyState === this.DONE) {
//             if (this.status === 200) {
//               resolve(this.response);
//             } else {
//               reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
//             }
//           }
//         };
//       });
//     }
  
//     getJSON('/posts.json').then(function(json) {
//       // on fulfillment
//     }, function(reason) {
//       // on rejection
//     });
//     ```
  
//     Unlike callbacks, promises are great composable primitives.
  
//     ```js
//     Promise.all([
//       getJSON('/posts'),
//       getJSON('/comments')
//     ]).then(function(values){
//       values[0] // => postsJSON
//       values[1] // => commentsJSON
  
//       return values;
//     });
//     ```
  
//     @class Promise
//     @param {Function} resolver
//     Useful for tooling.
//     @constructor
//   */

//   var Promise$1 = function () {
//     function Promise(resolver) {
//       this[PROMISE_ID] = nextId();
//       this._result = this._state = undefined;
//       this._subscribers = [];

//       if (noop !== resolver) {
//         typeof resolver !== 'function' && needsResolver();
//         this instanceof Promise ? initializePromise(this, resolver) : needsNew();
//       }
//     }

//     /**
//     The primary way of interacting with a promise is through its `then` method,
//     which registers callbacks to receive either a promise's eventual value or the
//     reason why the promise cannot be fulfilled.
//      ```js
//     findUser().then(function(user){
//       // user is available
//     }, function(reason){
//       // user is unavailable, and you are given the reason why
//     });
//     ```
//      Chaining
//     --------
//      The return value of `then` is itself a promise.  This second, 'downstream'
//     promise is resolved with the return value of the first promise's fulfillment
//     or rejection handler, or rejected if the handler throws an exception.
//      ```js
//     findUser().then(function (user) {
//       return user.name;
//     }, function (reason) {
//       return 'default name';
//     }).then(function (userName) {
//       // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
//       // will be `'default name'`
//     });
//      findUser().then(function (user) {
//       throw new Error('Found user, but still unhappy');
//     }, function (reason) {
//       throw new Error('`findUser` rejected and we're unhappy');
//     }).then(function (value) {
//       // never reached
//     }, function (reason) {
//       // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
//       // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
//     });
//     ```
//     If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
//      ```js
//     findUser().then(function (user) {
//       throw new PedagogicalException('Upstream error');
//     }).then(function (value) {
//       // never reached
//     }).then(function (value) {
//       // never reached
//     }, function (reason) {
//       // The `PedgagocialException` is propagated all the way down to here
//     });
//     ```
//      Assimilation
//     ------------
//      Sometimes the value you want to propagate to a downstream promise can only be
//     retrieved asynchronously. This can be achieved by returning a promise in the
//     fulfillment or rejection handler. The downstream promise will then be pending
//     until the returned promise is settled. This is called *assimilation*.
//      ```js
//     findUser().then(function (user) {
//       return findCommentsByAuthor(user);
//     }).then(function (comments) {
//       // The user's comments are now available
//     });
//     ```
//      If the assimliated promise rejects, then the downstream promise will also reject.
//      ```js
//     findUser().then(function (user) {
//       return findCommentsByAuthor(user);
//     }).then(function (comments) {
//       // If `findCommentsByAuthor` fulfills, we'll have the value here
//     }, function (reason) {
//       // If `findCommentsByAuthor` rejects, we'll have the reason here
//     });
//     ```
//      Simple Example
//     --------------
//      Synchronous Example
//      ```javascript
//     let result;
//      try {
//       result = findResult();
//       // success
//     } catch(reason) {
//       // failure
//     }
//     ```
//      Errback Example
//      ```js
//     findResult(function(result, err){
//       if (err) {
//         // failure
//       } else {
//         // success
//       }
//     });
//     ```
//      Promise Example;
//      ```javascript
//     findResult().then(function(result){
//       // success
//     }, function(reason){
//       // failure
//     });
//     ```
//      Advanced Example
//     --------------
//      Synchronous Example
//      ```javascript
//     let author, books;
//      try {
//       author = findAuthor();
//       books  = findBooksByAuthor(author);
//       // success
//     } catch(reason) {
//       // failure
//     }
//     ```
//      Errback Example
//      ```js
//      function foundBooks(books) {
//      }
//      function failure(reason) {
//      }
//      findAuthor(function(author, err){
//       if (err) {
//         failure(err);
//         // failure
//       } else {
//         try {
//           findBoooksByAuthor(author, function(books, err) {
//             if (err) {
//               failure(err);
//             } else {
//               try {
//                 foundBooks(books);
//               } catch(reason) {
//                 failure(reason);
//               }
//             }
//           });
//         } catch(error) {
//           failure(err);
//         }
//         // success
//       }
//     });
//     ```
//      Promise Example;
//      ```javascript
//     findAuthor().
//       then(findBooksByAuthor).
//       then(function(books){
//         // found books
//     }).catch(function(reason){
//       // something went wrong
//     });
//     ```
//      @method then
//     @param {Function} onFulfilled
//     @param {Function} onRejected
//     Useful for tooling.
//     @return {Promise}
//     */

//     /**
//     `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
//     as the catch block of a try/catch statement.
//     ```js
//     function findAuthor(){
//     throw new Error('couldn't find that author');
//     }
//     // synchronous
//     try {
//     findAuthor();
//     } catch(reason) {
//     // something went wrong
//     }
//     // async with promises
//     findAuthor().catch(function(reason){
//     // something went wrong
//     });
//     ```
//     @method catch
//     @param {Function} onRejection
//     Useful for tooling.
//     @return {Promise}
//     */


//     Promise.prototype.catch = function _catch(onRejection) {
//       return this.then(null, onRejection);
//     };

//     /**
//       `finally` will be invoked regardless of the promise's fate just as native
//       try/catch/finally behaves
    
//       Synchronous example:
    
//       ```js
//       findAuthor() {
//         if (Math.random() > 0.5) {
//           throw new Error();
//         }
//         return new Author();
//       }
    
//       try {
//         return findAuthor(); // succeed or fail
//       } catch(error) {
//         return findOtherAuther();
//       } finally {
//         // always runs
//         // doesn't affect the return value
//       }
//       ```
    
//       Asynchronous example:
    
//       ```js
//       findAuthor().catch(function(reason){
//         return findOtherAuther();
//       }).finally(function(){
//         // author was either found, or not
//       });
//       ```
    
//       @method finally
//       @param {Function} callback
//       @return {Promise}
//     */


//     Promise.prototype.finally = function _finally(callback) {
//       var promise = this;
//       var constructor = promise.constructor;

//       return promise.then(function (value) {
//         return constructor.resolve(callback()).then(function () {
//           return value;
//         });
//       }, function (reason) {
//         return constructor.resolve(callback()).then(function () {
//           throw reason;
//         });
//       });
//     };

//     return Promise;
//   }();

//   Promise$1.prototype.then = then;
//   Promise$1.all = all;
//   Promise$1.race = race;
//   Promise$1.resolve = resolve$1;
//   Promise$1.reject = reject$1;
//   Promise$1._setScheduler = setScheduler;
//   Promise$1._setAsap = setAsap;
//   Promise$1._asap = asap;

//   /*global self*/
//   function polyfill() {
//     var local = void 0;

//     if (typeof global !== 'undefined') {
//       local = global;
//     } else if (typeof self !== 'undefined') {
//       local = self;
//     } else {
//       try {
//         local = Function('return this')();
//       } catch (e) {
//         throw new Error('polyfill failed because global object is unavailable in this environment');
//       }
//     }

//     var P = local.Promise;

//     if (P) {
//       var promiseToString = null;
//       try {
//         promiseToString = Object.prototype.toString.call(P.resolve());
//       } catch (e) {
//         // silently ignored
//       }

//       if (promiseToString === '[object Promise]' && !P.cast) {
//         return;
//       }
//     }

//     local.Promise = Promise$1;
//   }

//   // Strange compat..
//   Promise$1.polyfill = polyfill;
//   Promise$1.Promise = Promise$1;

//   return Promise$1;

// })));

// /*!
//  * @overview es6-promise - a tiny implementation of Promises/A+.
//  * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
//  * @license   Licensed under MIT license
//  *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
//  * @version   v4.2.2+97478eb6
//  */
// (function (global) {
//   global.regeneratorRuntime = (function (exports) {
//     "use strict";

//     var Op = Object.prototype;
//     var hasOwn = Op.hasOwnProperty;
//     var undefined; // More compressible than void 0.
//     var $Symbol = typeof Symbol === "function" ? Symbol : {};
//     var iteratorSymbol = $Symbol.iterator || "@@iterator";
//     var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
//     var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";

//     function wrap(innerFn, outerFn, self, tryLocsList) {
//       // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
//       var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
//       var generator = Object.create(protoGenerator.prototype);
//       var context = new Context(tryLocsList || []);

//       // The ._invoke method unifies the implementations of the .next,
//       // .throw, and .return methods.
//       generator._invoke = makeInvokeMethod(innerFn, self, context);

//       return generator;
//     }
//     exports.wrap = wrap;

//     // Try/catch helper to minimize deoptimizations. Returns a completion
//     // record like context.tryEntries[i].completion. This interface could
//     // have been (and was previously) designed to take a closure to be
//     // invoked without arguments, but in all the cases we care about we
//     // already have an existing method we want to call, so there's no need
//     // to create a new function object. We can even get away with assuming
//     // the method takes exactly one argument, since that happens to be true
//     // in every case, so we don't have to touch the arguments object. The
//     // only additional allocation required is the completion record, which
//     // has a stable shape and so hopefully should be cheap to allocate.
//     function tryCatch(fn, obj, arg) {
//       try {
//         return { type: "normal", arg: fn.call(obj, arg) };
//       } catch (err) {
//         return { type: "throw", arg: err };
//       }
//     }

//     var GenStateSuspendedStart = "suspendedStart";
//     var GenStateSuspendedYield = "suspendedYield";
//     var GenStateExecuting = "executing";
//     var GenStateCompleted = "completed";

//     // Returning this object from the innerFn has the same effect as
//     // breaking out of the dispatch switch statement.
//     var ContinueSentinel = {};

//     // Dummy constructor functions that we use as the .constructor and
//     // .constructor.prototype properties for functions that return Generator
//     // objects. For full spec compliance, you may wish to configure your
//     // minifier not to mangle the names of these two functions.
//     function Generator() { }
//     function GeneratorFunction() { }
//     function GeneratorFunctionPrototype() { }

//     // This is a polyfill for %IteratorPrototype% for environments that
//     // don't natively support it.
//     var IteratorPrototype = {};
//     IteratorPrototype[iteratorSymbol] = function () {
//       return this;
//     };

//     var getProto = Object.getPrototypeOf;
//     var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
//     if (NativeIteratorPrototype &&
//       NativeIteratorPrototype !== Op &&
//       hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
//       // This environment has a native %IteratorPrototype%; use it instead
//       // of the polyfill.
//       IteratorPrototype = NativeIteratorPrototype;
//     }

//     var Gp = GeneratorFunctionPrototype.prototype =
//       Generator.prototype = Object.create(IteratorPrototype);
//     GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
//     GeneratorFunctionPrototype.constructor = GeneratorFunction;
//     GeneratorFunctionPrototype[toStringTagSymbol] =
//       GeneratorFunction.displayName = "GeneratorFunction";

//     // Helper for defining the .next, .throw, and .return methods of the
//     // Iterator interface in terms of a single ._invoke method.
//     function defineIteratorMethods(prototype) {
//       ["next", "throw", "return"].forEach(function (method) {
//         prototype[method] = function (arg) {
//           return this._invoke(method, arg);
//         };
//       });
//     }

//     exports.isGeneratorFunction = function (genFun) {
//       var ctor = typeof genFun === "function" && genFun.constructor;
//       return ctor
//         ? ctor === GeneratorFunction ||
//         // For the native GeneratorFunction constructor, the best we can
//         // do is to check its .name property.
//         (ctor.displayName || ctor.name) === "GeneratorFunction"
//         : false;
//     };

//     exports.mark = function (genFun) {
//       if (Object.setPrototypeOf) {
//         Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
//       } else {
//         genFun.__proto__ = GeneratorFunctionPrototype;
//         if (!(toStringTagSymbol in genFun)) {
//           genFun[toStringTagSymbol] = "GeneratorFunction";
//         }
//       }
//       genFun.prototype = Object.create(Gp);
//       return genFun;
//     };

//     // Within the body of any async function, `await x` is transformed to
//     // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
//     // `hasOwn.call(value, "__await")` to determine if the yielded value is
//     // meant to be awaited.
//     exports.awrap = function (arg) {
//       return { __await: arg };
//     };

//     function AsyncIterator(generator) {
//       function invoke(method, arg, resolve, reject) {
//         var record = tryCatch(generator[method], generator, arg);
//         if (record.type === "throw") {
//           reject(record.arg);
//         } else {
//           var result = record.arg;
//           var value = result.value;
//           if (value &&
//             typeof value === "object" &&
//             hasOwn.call(value, "__await")) {
//             return Promise.resolve(value.__await).then(function (value) {
//               invoke("next", value, resolve, reject);
//             }, function (err) {
//               invoke("throw", err, resolve, reject);
//             });
//           }

//           return Promise.resolve(value).then(function (unwrapped) {
//             // When a yielded Promise is resolved, its final value becomes
//             // the .value of the Promise<{value,done}> result for the
//             // current iteration.
//             result.value = unwrapped;
//             resolve(result);
//           }, function (error) {
//             // If a rejected Promise was yielded, throw the rejection back
//             // into the async generator function so it can be handled there.
//             return invoke("throw", error, resolve, reject);
//           });
//         }
//       }

//       var previousPromise;

//       function enqueue(method, arg) {
//         function callInvokeWithMethodAndArg() {
//           return new Promise(function (resolve, reject) {
//             invoke(method, arg, resolve, reject);
//           });
//         }

//         return previousPromise =
//           // If enqueue has been called before, then we want to wait until
//           // all previous Promises have been resolved before calling invoke,
//           // so that results are always delivered in the correct order. If
//           // enqueue has not been called before, then it is important to
//           // call invoke immediately, without waiting on a callback to fire,
//           // so that the async generator function has the opportunity to do
//           // any necessary setup in a predictable way. This predictability
//           // is why the Promise constructor synchronously invokes its
//           // executor callback, and why async functions synchronously
//           // execute code before the first await. Since we implement simple
//           // async functions in terms of async generators, it is especially
//           // important to get this right, even though it requires care.
//           previousPromise ? previousPromise.then(
//             callInvokeWithMethodAndArg,
//             // Avoid propagating failures to Promises returned by later
//             // invocations of the iterator.
//             callInvokeWithMethodAndArg
//           ) : callInvokeWithMethodAndArg();
//       }

//       // Define the unified helper method that is used to implement .next,
//       // .throw, and .return (see defineIteratorMethods).
//       this._invoke = enqueue;
//     }

//     defineIteratorMethods(AsyncIterator.prototype);
//     AsyncIterator.prototype[asyncIteratorSymbol] = function () {
//       return this;
//     };
//     exports.AsyncIterator = AsyncIterator;

//     // Note that simple async functions are implemented on top of
//     // AsyncIterator objects; they just return a Promise for the value of
//     // the final result produced by the iterator.
//     exports.async = function (innerFn, outerFn, self, tryLocsList) {
//       var iter = new AsyncIterator(
//         wrap(innerFn, outerFn, self, tryLocsList)
//       );

//       return exports.isGeneratorFunction(outerFn)
//         ? iter // If outerFn is a generator, return the full iterator.
//         : iter.next().then(function (result) {
//           return result.done ? result.value : iter.next();
//         });
//     };

//     function makeInvokeMethod(innerFn, self, context) {
//       var state = GenStateSuspendedStart;

//       return function invoke(method, arg) {
//         if (state === GenStateExecuting) {
//           throw new Error("Generator is already running");
//         }

//         if (state === GenStateCompleted) {
//           if (method === "throw") {
//             throw arg;
//           }

//           // Be forgiving, per 25.3.3.3.3 of the spec:
//           // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
//           return doneResult();
//         }

//         context.method = method;
//         context.arg = arg;

//         while (true) {
//           var delegate = context.delegate;
//           if (delegate) {
//             var delegateResult = maybeInvokeDelegate(delegate, context);
//             if (delegateResult) {
//               if (delegateResult === ContinueSentinel) continue;
//               return delegateResult;
//             }
//           }

//           if (context.method === "next") {
//             // Setting context._sent for legacy support of Babel's
//             // function.sent implementation.
//             context.sent = context._sent = context.arg;

//           } else if (context.method === "throw") {
//             if (state === GenStateSuspendedStart) {
//               state = GenStateCompleted;
//               throw context.arg;
//             }

//             context.dispatchException(context.arg);

//           } else if (context.method === "return") {
//             context.abrupt("return", context.arg);
//           }

//           state = GenStateExecuting;

//           var record = tryCatch(innerFn, self, context);
//           if (record.type === "normal") {
//             // If an exception is thrown from innerFn, we leave state ===
//             // GenStateExecuting and loop back for another invocation.
//             state = context.done
//               ? GenStateCompleted
//               : GenStateSuspendedYield;

//             if (record.arg === ContinueSentinel) {
//               continue;
//             }

//             return {
//               value: record.arg,
//               done: context.done
//             };

//           } else if (record.type === "throw") {
//             state = GenStateCompleted;
//             // Dispatch the exception by looping back around to the
//             // context.dispatchException(context.arg) call above.
//             context.method = "throw";
//             context.arg = record.arg;
//           }
//         }
//       };
//     }

//     // Call delegate.iterator[context.method](context.arg) and handle the
//     // result, either by returning a { value, done } result from the
//     // delegate iterator, or by modifying context.method and context.arg,
//     // setting context.delegate to null, and returning the ContinueSentinel.
//     function maybeInvokeDelegate(delegate, context) {
//       var method = delegate.iterator[context.method];
//       if (method === undefined) {
//         // A .throw or .return when the delegate iterator has no .throw
//         // method always terminates the yield* loop.
//         context.delegate = null;

//         if (context.method === "throw") {
//           if (delegate.iterator.return) {
//             // If the delegate iterator has a return method, give it a
//             // chance to clean up.
//             context.method = "return";
//             context.arg = undefined;
//             maybeInvokeDelegate(delegate, context);

//             if (context.method === "throw") {
//               // If maybeInvokeDelegate(context) changed context.method from
//               // "return" to "throw", let that override the TypeError below.
//               return ContinueSentinel;
//             }
//           }

//           context.method = "throw";
//           context.arg = new TypeError(
//             "The iterator does not provide a 'throw' method");
//         }

//         return ContinueSentinel;
//       }

//       var record = tryCatch(method, delegate.iterator, context.arg);

//       if (record.type === "throw") {
//         context.method = "throw";
//         context.arg = record.arg;
//         context.delegate = null;
//         return ContinueSentinel;
//       }

//       var info = record.arg;

//       if (!info) {
//         context.method = "throw";
//         context.arg = new TypeError("iterator result is not an object");
//         context.delegate = null;
//         return ContinueSentinel;
//       }

//       if (info.done) {
//         // Assign the result of the finished delegate to the temporary
//         // variable specified by delegate.resultName (see delegateYield).
//         context[delegate.resultName] = info.value;

//         // Resume execution at the desired location (see delegateYield).
//         context.next = delegate.nextLoc;

//         // If context.method was "throw" but the delegate handled the
//         // exception, let the outer generator proceed normally. If
//         // context.method was "next", forget context.arg since it has been
//         // "consumed" by the delegate iterator. If context.method was
//         // "return", allow the original .return call to continue in the
//         // outer generator.
//         if (context.method !== "return") {
//           context.method = "next";
//           context.arg = undefined;
//         }

//       } else {
//         // Re-yield the result returned by the delegate method.
//         return info;
//       }

//       // The delegate iterator is finished, so forget it and continue with
//       // the outer generator.
//       context.delegate = null;
//       return ContinueSentinel;
//     }

//     // Define Generator.prototype.{next,throw,return} in terms of the
//     // unified ._invoke helper method.
//     defineIteratorMethods(Gp);

//     Gp[toStringTagSymbol] = "Generator";

//     // A Generator should always return itself as the iterator object when the
//     // @@iterator function is called on it. Some browsers' implementations of the
//     // iterator prototype chain incorrectly implement this, causing the Generator
//     // object to not be returned from this call. This ensures that doesn't happen.
//     // See https://github.com/facebook/regenerator/issues/274 for more details.
//     Gp[iteratorSymbol] = function () {
//       return this;
//     };

//     Gp.toString = function () {
//       return "[object Generator]";
//     };

//     function pushTryEntry(locs) {
//       var entry = { tryLoc: locs[0] };

//       if (1 in locs) {
//         entry.catchLoc = locs[1];
//       }

//       if (2 in locs) {
//         entry.finallyLoc = locs[2];
//         entry.afterLoc = locs[3];
//       }

//       this.tryEntries.push(entry);
//     }

//     function resetTryEntry(entry) {
//       var record = entry.completion || {};
//       record.type = "normal";
//       delete record.arg;
//       entry.completion = record;
//     }

//     function Context(tryLocsList) {
//       // The root entry object (effectively a try statement without a catch
//       // or a finally block) gives us a place to store values thrown from
//       // locations where there is no enclosing try statement.
//       this.tryEntries = [{ tryLoc: "root" }];
//       tryLocsList.forEach(pushTryEntry, this);
//       this.reset(true);
//     }

//     exports.keys = function (object) {
//       var keys = [];
//       for (var key in object) {
//         keys.push(key);
//       }
//       keys.reverse();

//       // Rather than returning an object with a next method, we keep
//       // things simple and return the next function itself.
//       return function next() {
//         while (keys.length) {
//           var key = keys.pop();
//           if (key in object) {
//             next.value = key;
//             next.done = false;
//             return next;
//           }
//         }

//         // To avoid creating an additional object, we just hang the .value
//         // and .done properties off the next function object itself. This
//         // also ensures that the minifier will not anonymize the function.
//         next.done = true;
//         return next;
//       };
//     };

//     function values(iterable) {
//       if (iterable) {
//         var iteratorMethod = iterable[iteratorSymbol];
//         if (iteratorMethod) {
//           return iteratorMethod.call(iterable);
//         }

//         if (typeof iterable.next === "function") {
//           return iterable;
//         }

//         if (!isNaN(iterable.length)) {
//           var i = -1, next = function next() {
//             while (++i < iterable.length) {
//               if (hasOwn.call(iterable, i)) {
//                 next.value = iterable[i];
//                 next.done = false;
//                 return next;
//               }
//             }

//             next.value = undefined;
//             next.done = true;

//             return next;
//           };

//           return next.next = next;
//         }
//       }

//       // Return an iterator with no values.
//       return { next: doneResult };
//     }
//     exports.values = values;

//     function doneResult() {
//       return { value: undefined, done: true };
//     }

//     Context.prototype = {
//       constructor: Context,

//       reset: function (skipTempReset) {
//         this.prev = 0;
//         this.next = 0;
//         // Resetting context._sent for legacy support of Babel's
//         // function.sent implementation.
//         this.sent = this._sent = undefined;
//         this.done = false;
//         this.delegate = null;

//         this.method = "next";
//         this.arg = undefined;

//         this.tryEntries.forEach(resetTryEntry);

//         if (!skipTempReset) {
//           for (var name in this) {
//             // Not sure about the optimal order of these conditions:
//             if (name.charAt(0) === "t" &&
//               hasOwn.call(this, name) &&
//               !isNaN(+name.slice(1))) {
//               this[name] = undefined;
//             }
//           }
//         }
//       },

//       stop: function () {
//         this.done = true;

//         var rootEntry = this.tryEntries[0];
//         var rootRecord = rootEntry.completion;
//         if (rootRecord.type === "throw") {
//           throw rootRecord.arg;
//         }

//         return this.rval;
//       },

//       dispatchException: function (exception) {
//         if (this.done) {
//           throw exception;
//         }

//         var context = this;
//         function handle(loc, caught) {
//           record.type = "throw";
//           record.arg = exception;
//           context.next = loc;

//           if (caught) {
//             // If the dispatched exception was caught by a catch block,
//             // then let that catch block handle the exception normally.
//             context.method = "next";
//             context.arg = undefined;
//           }

//           return !!caught;
//         }

//         for (var i = this.tryEntries.length - 1; i >= 0; --i) {
//           var entry = this.tryEntries[i];
//           var record = entry.completion;

//           if (entry.tryLoc === "root") {
//             // Exception thrown outside of any try block that could handle
//             // it, so set the completion value of the entire function to
//             // throw the exception.
//             return handle("end");
//           }

//           if (entry.tryLoc <= this.prev) {
//             var hasCatch = hasOwn.call(entry, "catchLoc");
//             var hasFinally = hasOwn.call(entry, "finallyLoc");

//             if (hasCatch && hasFinally) {
//               if (this.prev < entry.catchLoc) {
//                 return handle(entry.catchLoc, true);
//               } else if (this.prev < entry.finallyLoc) {
//                 return handle(entry.finallyLoc);
//               }

//             } else if (hasCatch) {
//               if (this.prev < entry.catchLoc) {
//                 return handle(entry.catchLoc, true);
//               }

//             } else if (hasFinally) {
//               if (this.prev < entry.finallyLoc) {
//                 return handle(entry.finallyLoc);
//               }

//             } else {
//               throw new Error("try statement without catch or finally");
//             }
//           }
//         }
//       },

//       abrupt: function (type, arg) {
//         for (var i = this.tryEntries.length - 1; i >= 0; --i) {
//           var entry = this.tryEntries[i];
//           if (entry.tryLoc <= this.prev &&
//             hasOwn.call(entry, "finallyLoc") &&
//             this.prev < entry.finallyLoc) {
//             var finallyEntry = entry;
//             break;
//           }
//         }

//         if (finallyEntry &&
//           (type === "break" ||
//             type === "continue") &&
//           finallyEntry.tryLoc <= arg &&
//           arg <= finallyEntry.finallyLoc) {
//           // Ignore the finally entry if control is not jumping to a
//           // location outside the try/catch block.
//           finallyEntry = null;
//         }

//         var record = finallyEntry ? finallyEntry.completion : {};
//         record.type = type;
//         record.arg = arg;

//         if (finallyEntry) {
//           this.method = "next";
//           this.next = finallyEntry.finallyLoc;
//           return ContinueSentinel;
//         }

//         return this.complete(record);
//       },

//       complete: function (record, afterLoc) {
//         if (record.type === "throw") {
//           throw record.arg;
//         }

//         if (record.type === "break" ||
//           record.type === "continue") {
//           this.next = record.arg;
//         } else if (record.type === "return") {
//           this.rval = this.arg = record.arg;
//           this.method = "return";
//           this.next = "end";
//         } else if (record.type === "normal" && afterLoc) {
//           this.next = afterLoc;
//         }

//         return ContinueSentinel;
//       },

//       finish: function (finallyLoc) {
//         for (var i = this.tryEntries.length - 1; i >= 0; --i) {
//           var entry = this.tryEntries[i];
//           if (entry.finallyLoc === finallyLoc) {
//             this.complete(entry.completion, entry.afterLoc);
//             resetTryEntry(entry);
//             return ContinueSentinel;
//           }
//         }
//       },

//       "catch": function (tryLoc) {
//         for (var i = this.tryEntries.length - 1; i >= 0; --i) {
//           var entry = this.tryEntries[i];
//           if (entry.tryLoc === tryLoc) {
//             var record = entry.completion;
//             if (record.type === "throw") {
//               var thrown = record.arg;
//               resetTryEntry(entry);
//             }
//             return thrown;
//           }
//         }

//         // The context.catch method must only be called with a location
//         // argument that corresponds to a known catch block.
//         throw new Error("illegal catch attempt");
//       },

//       delegateYield: function (iterable, resultName, nextLoc) {
//         this.delegate = {
//           iterator: values(iterable),
//           resultName: resultName,
//           nextLoc: nextLoc
//         };

//         if (this.method === "next") {
//           // Deliberately forget the last sent value so that we don't
//           // accidentally pass it on to the delegate.
//           this.arg = undefined;
//         }

//         return ContinueSentinel;
//       }
//     };

//     // Regardless of whether this script is executing as a CommonJS module
//     // or not, return the runtime object so that we can declare the variable
//     // regeneratorRuntime in the outer scope, which allows this module to be
//     // injected easily by `bin/regenerator --include-runtime script.js`.
//     return exports;

//   }(
//     // If this script is executing as a CommonJS module, use module.exports
//     // as the regeneratorRuntime namespace. Otherwise create a new empty
//     // object. Either way, the resulting object will be used to initialize
//     // the regeneratorRuntime variable at the top of this file.
//     typeof module === "object" ? module.exports : {}
//   ));
// })(window || this);